package com.spring.beans.factory.support;

import com.spring.BeanDefinition;
import com.spring.beans.BeansException;
import com.spring.beans.factory.config.AutowireCapableBeanFactory;

/**
 * @Author: Asuka
 * @Description:
 * @create: 2025-04-14 13:59
 */


public class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory
    implements AutowireCapableBeanFactory {

    private InstantiationStrategy instantiationStrategy = new SimpleInstantiationStrategy();



    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) throws BeansException {
        //如果bean需要代理，则直接返回代理对象
        Object bean = resolveBeforeInstantiation(beanName,beanDefinition);
        if(bean != null){
            return bean;
        }

        return doCreateBean(beanName, beanDefinition);
    }


    //执行InstantiationAwareBeanPostProcessor的方法，如果bean需要代理，直接返回代理对象
    private Object resolveBeforeInstantiation(String name, BeanDefinition beanDefinition) {
        applyBeanPostProcessorsBeforeInitialization(beanDefinition.getBeanClass(),name);
        //if(bean)
        // TODO
        return null;
    }

    private Object doCreateBean(String name, BeanDefinition beanDefinition) {
        return null;
    }

    @Override
    public Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName) throws BeansException {
        return null;
    }

    @Override
    public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName) throws BeansException {
        return null;
    }

    @Override
    protected boolean containsBeanDefinition(String beanName) {
        return false;
    }



    @Override
    protected BeanDefinition getBeanDefinition(String beanName) {
        return null;
    }

    @Override
    public <T> T getBean(Class<T> requiredType) throws BeansException {
        return null;
    }
}
